<html>

<head>
    <meta charset="utf-8">
    <meta name="author" content="lz">
    <title></title>
    <script src="jQuery/jquery-3.1.1.js"></script>
    <style>
        body {
            font: 12px/1.5 arial;
            color: #666;
        }
        
        ul,
        p {
            margin: 0;
            padding: 0;
        }
        
        #star {
            width: 600px;
        }
        
        #star span,
        #star ul {
            float: left;
            margin: 0 5px;
        }
        
        #star li {
            float: left;
            width: 24px;
            height: 24px;
            cursor: pointer;
            list-style: none;
            background-image: url(img/star.png);
            background-repeat: no-repeat;
        }
        
        #star li.on {
            background-position: 0 -28px;
        }
        
        #star p {
            position: absolute;
            top: 40px;
            width: 120px;
        }
        
        #star p em {
            display: block;
            font-style: normal;
            color: #f60;
        }
        
        #star strong {
            color: #f60;
        }
    </style>
</head>

<body>
    <div id="star">
        <span>点击星星评分</span>
        <ul>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>

        <!--显示最终评分效果-->
        <span></span>

        <!--显示评语及效果-->
        <p></p>
    </div>
</body>

</html>
<script>
    window.onload = function () {
        var star = $('#star');
        var aLi = $('li');
        var span = $('span')[1];
        var p = $('p')[0];
        var ul = $('ul')[0];
        var msg = [
            "很不满意|差得太离谱，与卖家描述的严重不符，非常不满",
            "不满意|部分有破损，与卖家描述的不符，不满意",
            "一般|质量一般，没有卖家描述的那么好",
            "满意|质量不错，与卖家描述的基本一致，还是挺满意的",
            "非常满意|质量非常好，与卖家描述的完全一致，非常满意"
        ];

        var isStar = 0;
        $('li').each(function(i){
            $('li')[i].index = i;
            $('li')[i].onmouseover = function () {
                showStar(this.index + 1);
                p.innerHTML = '<em><b>' + (this.index + 1) + '<b> 分' + msg[this.index].split('|')[0] + '</em>' + msg[this.index].split('|')[1];
                p.style.left = ul.offsetLeft + this.offsetWidth * this.index + 'px';
            }
            $('li')[i].onclick = function () {
                isStar = this.index + 1;
                p.innerHTML = '';
                span.innerHTML = '<strong>' + isStar + '分</strong>(' + msg[this.index].split('|')[1] + ')';
            }
            $('li').onmouseout = function () {
                showStar(isStar);
            }
        });

        function showStar(index) {
            $('li').each(function(i){
                $('li')[i].className = i < index ? 'on' : '';
            });  
        }
    }

</script>